import threading
import os
import random
import time

"""
多线程的设计: 
    import threading
    多线程相比多进程的区别:
        多线程更加轻量化,使得io处理更加迅速
        
"""

def thread_handler(delay):
    for i in range(10):
        time.sleep(delay)
        print('[{}]  id:[{}]  叫了第{}声'.format(threading.current_thread().name,threading.current_thread().ident,i))

def main():
    th_dogs = [threading.Thread(target=thread_handler,args=(2,),name='修狗{}'.format(id)) for id in range(5)]
    for th_dog in th_dogs:
        th_dog.start()
    for th_dog in th_dogs:
        th_dog.join()


if __name__ == '__main__':
    main()